package com.ok.common.mqtt

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken
import org.eclipse.paho.client.mqttv3.IMqttToken

interface MqttListener {
    /**
     * 收到消息
     *
     * @param topic   主题
     * @param message 消息内容
     * @param qos     消息策略
     */
    fun messageArrived(topic: String, message: String, qos: Int)

    /**
     * 传送完成
     *
     * @param deliveryToken
     */
    fun deliveryComplete(deliveryToken: IMqttDeliveryToken)

    /**
     * 连接成功
     *
     * @param mqttToken
     */
    fun connectSuccess(mqttToken: IMqttToken?, reconnect: Boolean)

    /**
     * 连接断开
     *
     * @param throwable 抛出的异常信息
     */
    fun connectionLost(throwable: Throwable?)

    /**
     * 连接失败
     *
     * @param msg
     */
    fun connectFailed(mqttToken: IMqttToken, msg: Throwable)

}